/**
 * @Author: Nick Zhang <thesadboy@vip.qq.com>
 * @Description: 生成头部注释
 * @Date: 2024-06-14 13:45:33
 * @LastEditors: Nick Zhang <thesadboy@vip.qq.com>
 * @LastEditTime: 2024-06-20 09:49:39
 */
package com.nickzhang.jetbrains.file_description_plugin.actions

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.nickzhang.jetbrains.file_description_plugin.utils.CommentUtil

class AppGenerateAction : AnAction() {
    override fun actionPerformed(e: AnActionEvent) {
        val editor: Editor = e.getData(CommonDataKeys.EDITOR) ?: return
        val document = editor.document
        val file = FileDocumentManager.getInstance().getFile(document) ?: return
        document.let { CommentUtil.checkAddCommentHeader(it, file) }
    }
}
